//
//  YXFeedbackViewController.m
//  跑跑快销
//
//  Created by 杨潇 on 14-5-4.
//  Copyright (c) 2014年 ylife. All rights reserved.
//

#import "YXFeedbackViewController.h"

@interface YXFeedbackViewController ()

@end

@implementation YXFeedbackViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    _feedbackVi = [[YXFeedbackView alloc] init];
    self.view = _feedbackVi;
    _feedbackVi.textVi.delegate = self;
    
    UIBarButtonItem * rightBtn = [[UIBarButtonItem alloc] initWithTitle:@"提交" style:UIBarButtonItemStyleBordered target:self action:@selector(touchSearchBtn)];
    self.navigationItem.rightBarButtonItem = rightBtn;
}

- (void)touchSearchBtn
{
    [self.view endEditing:YES];
    YXWindowInfo * windowInfo = [YXWindowInfo sharedWindowInfo];
    [NSURLConnection sendRequestWithHeadStr:[windowInfo requestUrlStr] headValue:[[windowInfo userInfoDic] objectForKey:@"token"] serviceToken:nil text:[NSDictionary dictionaryWithObjectsAndKeys:@"setFeedBack",@"type",_feedbackVi.textVi.text,@"ContentFeedback",[[[windowInfo userInfoDic] objectForKey:@"userInfo"] objectForKey:@"AccountID"],@"userId", nil] dataBlock:^(NSDictionary *dic) {
        NSString * resultCode = [dic objectForKey:@"resultCode"];
        if ([resultCode isEqualToString:@"0"]) {
            [[YXWindowAlertView sharedWindowAlert] showLableWithTitle:@"发送反馈成功。"];
            [self.navigationController popViewControllerAnimated:YES];
        }else{
            [[YXWindowAlertView sharedWindowAlert] showLableWithTitle:@"发送反馈失败。"];
        }
    }];
}

#pragma mark - UITextViewDelegate
- (void)textViewDidChange:(UITextView *)textView
{
    if (textView.text.length > 0) {
        _feedbackVi.placeholderLab.hidden = YES;
    }else{
        _feedbackVi.placeholderLab.hidden = NO;
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
